<template>
	<view class="">
		<view class="chiyou_block">
			<view class="chiyou_nav">
				<view class="nav_name">
					名称
				</view>
				<view class="nav_money">
					金额
				</view>
				<view class="nav_number">
					拥有/可赎
				</view>
				<view class="nav_idea">
					推荐
				</view>
			</view>
			<view class="chiyou_list" 
			v-for="(jijin, index) in jijinArray"
			:key = index
			@click="detail(jijin.code, jijin.name)">
				<view class="left">
					{{jijin.name}}
				</view>
				<view class="left_center">
					{{jijin.sumMoney.toFixed(2)}}
				</view>
				<view class="right_center">
					<!-- <view class="right_title">
						持有份额为:
					</view> -->
					<view class="allNumber">
						{{jijin.allNumber.toFixed(2)}}
					</view>
					<!-- <view class="right_title">
						满七天份额:
					</view> -->
					<view class="freeNumber">
						{{jijin.freeNumber.toFixed(2)}}
					</view>
				</view>
				<view class="right">
					{{jijin.ideasNumber.toFixed(2)}}
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	
	var _self;
	
	export default {
		data() {
			return {
				jijinArray:[],
				model: 'zs', // 模式 zy zs
				modelName: '止损', // 模式 止盈 止损
				modelIndex: 0, // 模式下标
				list: ["止盈","止损"]
			}
		},
		// 点击导航栏按钮触发
		onNavigationBarButtonTap(e) {
			if(e.text == '添加'){
				// console.log(e.text)
				this.add()
			}else if(e.text = '模式'){
				uni.showActionSheet({
					itemList: ["止盈","止损"],
					success: function (res) {
						// console.log(res);
						if(res.tapIndex == 0){
							_self.model = 'zy'
							_self.modelName = '止盈'
							_self.Init()
						}else {
							_self.model = 'zs'
							_self.modelName = '止损'
							_self.Init()
						}
					},
					fail: function (res) {
						// console.log(res.errMsg);
					}
				})
				
			}
		},
		// 下拉刷新触发
		onPullDownRefresh() {
			uni.stopPullDownRefresh()
			this.Init()
		},
		onLoad() {
			_self = this;
			this.Init()
		},
		methods: {
			async Init(){
				uni.showLoading({
					title:'加载中...',
					mask:false
				})
				_self.jijinArray = await _self.store.findListByModel(_self.model)
				uni.hideLoading()
			},
			detail(code, name) {
				// console.log('code为：'+code)
				// 跳转到详情页面
				uni.navigateTo({
					url: 'detail/detail?code='
					+code+'&name='+name
				})
			},
			add() {
				uni.navigateTo({
					url: 'form/form'
				})
			},
			
		},
		components:{
		}
	}
</script>

<style>
	@import url("me.css");
</style>
